package com.dawnling.butterknife;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.dawnling.butterknife.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 黄油刀使用demo
 * 参考：https://www.jianshu.com/p/2967d0342d80
 * <p>
 * 用法：
 * 1.工具栏File 找到Settings...或者使用快捷点Ctrl+Alt+s 打开。搜索zelezny下载插件并安装，重启Android Studio
 * 2.需要将光标移到setContentView(R.layout.acty_login)，将光标放到R.layout.acty_login，然后右键Generate就有了
 */
public class MainActivity extends BaseActivity {

    @BindView(R.id.tv)
    TextView tv;
    @BindView(R.id.btnClick)
    Button btnClick;
    private FragmentManager supportFragmentManager;
    private FragmentTransaction fragmentTransaction;
    private TestFragment testFragment;

    @Override
    public void initUI(Bundle savedInstanceState) {
        setContentView(R.layout.activity_main);

        supportFragmentManager = getSupportFragmentManager(); //获取管理者
        fragmentTransaction = supportFragmentManager.beginTransaction(); //开启事务
        testFragment = new TestFragment();//碎片
        fragmentTransaction.add(R.id.frameLayout, testFragment).commit();//提交事务
    }

    @OnClick(R.id.btnClick)
    public void onViewClicked() {
        Toast.makeText(this, "hello", Toast.LENGTH_SHORT).show();
    }
}
